package io.gitee.icefairy.client1

import cn.hutool.core.date.DateUtil
import io.gitee.icefairy.ice_license.LicenseUtil
import io.gitee.icefairy.ice_license.model.LicenseException
import kotlin.system.exitProcess

fun main(args: Array<String>) {
    val app = ClientApp()
    app.doCalc()
}

class ClientApp {
    val keys =
        "1E12FC1EBA645F248E496C28E48D12380917447624EB741E2DB1AEDAB6E0B9786BA7918E368BF91B4E72E6CE09EB4F8CFDE35FA56C69048BF4E15CD47A7AE276B2DEEFEA053ADA839122E231F9172BA679F6C680DA419A4B42FA34415EE8E1DD30A430F96B4D8B33535DF5EC0B63ABACA69ADA11504CEE47C49F71182795FD7E"
    val publicKey =
        "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCEJhDgJaDBPLYQu5loq5shvrBxmZc2kE1b2qHPxFrTu7GzwHmxTvXK+GlueIMgR//tIHHVlLKRVYvlEvh9KWkEWCASTdUx6sy10LZ+WppliFf82MMj3cCObxDVLcjigbiBF2Y/bCtdihyDSZ+noGMMVk4KLJD/aRoFvao2Gwa22QIDAQAB"

    fun doCalc() {
        try {
            val lc = LicenseUtil.checkLicense(keys, publicKey, "看图王")
            println("当前产品[${lc.product}]授权给[${lc.clientName}]使用至${DateUtil.formatDateTime(lc.end)}")
        } catch (le: LicenseException) {
            println("证书错误:" + le.message)
            exitProcess(0)
        }
    }
}